<template>
	<yd-list theme="4"> 
        <yd-list-item v-for="item, key in statistics" :key="key" @click.native="info(item)">
            <img slot="img" :src="pic(item)">
            <span slot="title" class="h4">{{item.name}} [{{item.attr_name}}] </span>
            <yd-list-other slot="other">
                <div>
                    <span class="red h2">销量:{{item.my_num+item.you_num}}</span>
                    <!-- <span class="demo-list-del-price">¥{{item.w_price}}</span> -->
                </div>
            </yd-list-other>

            <yd-list-other slot="other">
                <div>
                	<span class=" h4">自己销售 : {{item.my_num}}</span> , 
                	<span class=" h4">下级销售 : {{item.you_num}}</span>
                </div>
            </yd-list-other>

           

        </yd-list-item>
    </yd-list>

</template>

<script>

import { Cell } from 'mint-ui'
import { mapGetters, mapActions } from 'vuex'
import { cutImage } from '../../util/util'


export default {
	name: 'statistics',
	data () {
		return {
		}
	},

	computed: {
		...mapGetters([
		    'userdata',
		    'statistics',
		    'company_code',
		    'URL',
		]),

		
	},

	methods: {
		
		pic (item) {
			var result = this.URL.defaultImg;
			if(item.top_pic != undefined){
				try{
					var ttt = JSON.parse(item.top_pic);
	                result = cutImage(ttt[0]);
				} catch (err) {
					
				}
			}
			return result;
		},

		info (item) {
			console.log('info');
			console.log(item);

			this.$router.push({ 
				'name': 'statisticsseller', 
				'query' : { 
					'company_code' : this.company_code,
					'level_code' : this.userdata.level,
					'fx_level' : this.userdata.fx_level,
					'sale_code' : item.sale_code,
					'attr_id' : item.attr_id,
				}
			});

		},
	},

	created () {
		this.$store.dispatch('statistics', {
			'level_code' : this.userdata.level,
			'fx_level' : this.userdata.fx_level,
		});

	},


}
</script>

<style scoped>

.more {
	width: 100%;
	height: 50px;
	line-height: 50px;
	float: left;
	text-align: center;
}

</style>
